﻿using System.IO;
using gixoom.Dom.Block;

namespace gixoom.Dom.Storage.File
{
    public interface IFileStorage
    {
        /// <summary>
        /// Extracts file which corresponds to the specified root block id.
        /// </summary>
        /// <param name="rootBlockId">root block id of the file</param>
        /// <returns>name of the file extracted from storage or null if there is no such file
        /// or if there is no such file name in dictionary.</returns>
        /// <exception cref="System.ArgumentNullException"><i>rootBlockId</i> is a null reference.</exception>
        string ExtractFile(IBlockId rootBlockId);

        /// <summary>
        /// Saves file from the specified file stream to storage and returns its root block id.
        /// If for some reason the file cannot be saved in the storage than the function returns null.
        /// Stream is read from beginning, not from current position.
        /// </summary>
        /// <param name="stream">opened stream</param>
        /// <returns>root block id of the file saved in storage</returns>
        /// <exception cref="System.ArgumentNullException"><i>fileStream</i> is a null reference.</exception>
        /// <exception cref="System.ArgumentException"><i>fileStream</i> cannot be read or sought.</exception>
        IBlockId SaveFile(FileStream stream);

        /// <summary>
        /// Sets path for files extracted from storage.
        /// </summary>
        /// <param name="path">path for files extracted from storage</param>
        /// <exception cref="System.ArgumentNullException"><i>path</i> is a null reference.</exception>
        /// <exception cref="System.ArgumentException"><i>path</i> is an empty string.</exception>
        void SetPathForExtractedFiles(string path);

        /// <summary>
        /// Gets path for files extracted from storage.
        /// </summary>
        string PathForExtractedFiles
        {
            get;
        }
    }
}
